package chapterSystem.client;

import chapterSystem.client.entities.Pair;
import chapterSystem.client.entities.UnitInfo;
import chapterSystem.client.model.entitiesInt.*;
import chapterSystem.client.model.enums.ActivityType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

import java.util.List;
import java.util.Map;

@RemoteServiceRelativePath("ChapterSystemService")
public interface ChapterSystemService extends RemoteService {
    Brother login(String username, String pass);

    Brother checkCookie(String cookie);

    List<Report> getReportsById(int id);

    Pair<List<Order>, List<Order>> getOrdersById(int id);

    List<ChapterEvent> getEvents(int eventCount, java.sql.Date fromDate, java.sql.Date toDate);

    String createNewBrother(Brother brother, String password);

    String editBrother(Brother brother);

    UnitInfo getUnitInfo(int id);

    Map<String, Unit> getAllUnits();

    String addLog(final int brotherId, final ActivityType type, final String message);

    String submitOrderExecution(Order order, String briefReport);

    String createBattleOrder(Order order);

    String editBattleOrderText(Order order);

    String editExecutionReport(Order order);

    Brother getBrotherByLogin(String login);

    List<String> getBrotherLog(int brotherId);

    String submitReport(int brotherId, int eventId, String reportText);

    List<Report> getReportsByEvent(int eventId, int brotherRank);

    String editReport(Report report);

    String createEvent(ChapterEvent event);

    /**
     * Utility/Convenience class.
     * Use ChapterSystemService.App.getInstance() to access static instance of ChapterSystemServiceAsync
     */
    public static class App {
        private static ChapterSystemServiceAsync ourInstance = GWT.create(ChapterSystemService.class);

        public static synchronized ChapterSystemServiceAsync getInstance() {
            return ourInstance;
        }
    }
}
